// 右侧固定联系

// 获取
var phone = document.querySelector('.fix_con p:nth-child(1)')
var vb = document.querySelector('.fix_con p:nth-child(2)')
var vx = document.querySelector('.fix_con p:nth-child(3)')

var phone_code = phone.querySelector('span')
var vb_code = vb.querySelector('span')
var vx_code = vx.querySelector('span')

phone.addEventListener('mouseover', function() {
    phone_code.style.display = 'block';
})
phone.addEventListener('mouseout', function() {
    phone_code.style.display = 'none';
})
phone_code.addEventListener('mouseout', function() {
    phone_code.style.display = 'none';

})



vb.addEventListener('mouseover', function() {
    vb_code.style.display = 'block';
})
vb.addEventListener('mouseout', function() {
    vb_code.style.display = 'none';
})
vb_code.addEventListener('mouseout', function() {
    vb_code.style.display = 'none';

})

vx.addEventListener('mouseover', function() {
    vx_code.style.display = 'block';
})
vx.addEventListener('mouseout', function() {
    vx_code.style.display = 'none';
})
vx_code.addEventListener('mouseout', function() {
    vx_code.style.display = 'none';

})




// 返回顶部

var back = document.querySelector('.back')
    // 调用
backTop(back, 1000, 10)


// 封装返回顶部函数
function backTop(ele, target, bulong) {

    var timer = null;
    window.onscroll = function() {
        // 滚动条的高度
        var top = document.documentElement.scrollTop || document.body.scrollTop;

        if (top <= target) {
            ele.style.display = 'none';
        } else {
            ele.style.display = 'block';
        }
    }

    ele.onclick = function() {
        clearInterval(timer);

        // 获取滚动条的高度
        var top = document.documentElement.scrollTop || document.body.scrollTop;

        // 开启定时器
        timer = setInterval(function() {
            if (top < bulong) {
                top--;
            } else {
                top -= Math.floor(top / bulong);
            }
            document.documentElement.scrollTop = top;
            document.body.scrollTop = top;

            // 如果已经上去了，则清除定时器
            if (top <= 0) {
                clearInterval(timer);
            }
        }, 15);
    }
}


// 选项卡切换
function Tab() {
    // 包这所有图片的盒子
    this.aud = document.querySelector('.aud');
    // 所有span
    this.spans = this.aud.querySelectorAll('span');
    // 抱着所有li
    this.aud_list = document.querySelector('.aud_list');
    this.p3_a = this.aud_list.querySelectorAll('.p3 span a')
        // 所有lis
    this.lis = this.aud_list.querySelectorAll('li');
}
Tab.prototype.init = function() {

    for (var i = 0; i < this.lis.length; i++) {
        this.lis[i].index = i;
        var _this = this;
        // 点击事件添加 
        this.lis[i].onmouseover = function() {

            for (var i = 0; i < _this.spans.length; i++) {
                _this.spans[i].style.display = 'none';
                _this.lis[i].style.backgroundColor = '#fff';
                _this.p3_a[i].style.color = "#444";

            }
            _this.spans[this.index].style.display = 'block';
            _this.lis[this.index].style.backgroundColor = '#fff7f3'
            _this.p3_a[this.index].style.color = "#ff4a00";

        }
    }
}


// class选择模块

// 获取模块

function TabClass() {
    // 大盒子
    this.nic_con = document.querySelector('.nice_con');
    // 全部ul
    this.uls = this.nic_con.querySelectorAll('ul');
    // 选项选项
    this.nic_top = document.querySelector('.nic_top');

    // lis
    this.lis = this.nic_top.querySelectorAll(' ul li');

}
TabClass.prototype.init = function() {

    for (var i = 0; i < this.lis.length; i++) {
        this.lis[i].index = i;
        var _this = this;
        // 点击事件添加 
        this.lis[i].onmouseover = function() {

            for (var i = 0; i < _this.uls.length; i++) {
                _this.uls[i].style.display = 'none';
            }
            _this.uls[this.index].style.display = 'block';
        }
    }
}







// 底部广告弹出

var fixed_ad = document.querySelector('.fixed_ad');

var fixed_pic = document.querySelector('.fixed_pic');

var close = fixed_ad.querySelector('span');

// 点击弹出 
fixed_pic.addEventListener('click', function() {
    this.style.transform = 'translateX(-100%)';
    fixed_ad.style.transform = 'translateX(0%)';
})

close.addEventListener('click', function() {
    fixed_ad.style.transform = 'translateX(-100%)';
    fixed_pic.style.transform = 'translateX(0%)';
})